#ifndef _IPLATFORMPROXYINTERFACE_H_
#define _IPLATFORMPROXYINTERFACE_H_

#include <iostream>
#include <string>
#include <map>

#include "CommonType.h"

namespace zl
{

using PairParams = std::map<std::string, std::string>;

/// \brief 管理台消息通知
class IPlatformProxyObserver
{
public:
    virtual ~IPlatformProxyObserver() {}

    virtual int32_t EventPlatReply(const PairParams& data) = 0;
};

/// \brief 管理台接口类
class IPlatformProxyInterface
{
public:
    /// \brief 平台配置项
    struct PlatConfig
    {
        std::string remote_addr;    ///< 远程地址
        int32_t remote_port;        ///< 远程端口
        std::string local_addr;     ///< 本地地址
        int32_t local_port;         ///< 本地端口
    };

    /// \brief 错误码
    enum EPlatError
    {
        EPlatError_Success = 0x00,      ///< 成功
        EPlatError_Failed,              ///< 失败
        EPlatError_ComunicationError,   ///< 通信异常
        EPlatError_SendFailed,          ///< 发送失败
        EPlatError_Timeout,             ///< 超时
        EPlatError_InvalidData,         ///< 不正确的报文
        EPlatError_Uninitialized,       ///< 未初始化
        EPlatError_Unknown = 0xFF       ///< 未知错误
    };

    virtual ~IPlatformProxyInterface() {}

    /// \brief 初始化
    virtual int32_t Initialize(const PlatConfig& conf, IPlatformProxyObserver* obs) = 0;

    /// \brief 去初始化
    virtual int32_t Uninitialize() = 0;

    /// \brief 上传订单信息
    /// \note 包含存/取包信息
    virtual int32_t ReportOrderStatus(const std::string& cabinet_no, const zl::Order &order) = 0;

    /// \brief 上传支付信息
    virtual int32_t ReportPaidDetails(const std::string& cabinet_no, const zl::PaidDetail& data) = 0;

    /// \brief 上传柜子状态信息
    virtual int32_t ReportCabinetStatus(const std::string& cabinet_no, const zl::LockerVec& lockers) = 0;

    /// \brief 终端上传操作日志
    virtual int32_t ReportOperationLogs(const zl::OperLog& log) = 0;

    /// \brief 终端同步时间请求
    virtual int32_t RequestSynchronizeTime(const std::string& cabinet_no) = 0;

    /// \brief 查询异柜存包信息
    virtual int32_t RequestOrderDetails(const std::string& cabinet_no, const std::string& user_id, const std::string& user_code) = 0;

    /// \brief 回复远程开箱
    virtual int32_t ResponseOpenBox(const std::string& log_id, const std::string& cabinet_no, const std::string& box_no) = 0;

    /// \brief 回复远程清箱
    virtual int32_t ResponseClearBox(const std::string& log_id, const std::string& cabinet_no, const std::string& box_no) = 0;

    /// \brief 回复远程重启/关机
    virtual int32_t ResponseShutDown(const std::string& log_id, const std::string& cabinet_no, const std::string& oper_type) = 0;

};

} // namespace zl
#endif // _IPLATFORMINTERFACE_H_
